<template>
  <div name="confirm-fade">
    <div class="confirm" v-show="showFlag" @click.stop>
      <div class="confirm-wrapper">
        <div class="confirm-content">
          <i class="fa fa-times faincon" aria-hidden="true" @click="remove"></i>
          <p class="text">{{text}}</p>
          <div class="operate">
            <div @click="cancel" class="operate-btn left">{{cancelBtnText}}</div>
            <div @click="confirm" class="operate-btn">{{confirmBtnText}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  export default {
    props: {
      text: {
        type: String,
        default: ''
      },
      confirmBtnText: {
        type: String,
        default: '确定'
      },
      cancelBtnText: {
        type: String,
        default: '取消'
      }
    },
    data() {
      return {
        showFlag: false
      }
    },
    methods: {
      show() {
        this.showFlag = true
      },
      hide() {
        this.showFlag = false
      },
      cancel() {
        this.hide()
        this.$emit('cancel')
      },
      confirm() {
        this.hide()
        this.$emit('confirm')
      },
      remove() {
        this.hide()
      }
    }
  }
</script>

<style scoped lang="less" rel="stylesheet/less">


  .confirm {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 998;
    /*background-color: red;*/
    .confirm-wrapper {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 999;
    }
    .confirm-content {
      width: 270px;
      border-radius: 13px;
      background: #449d44;
      position: relative;

    }

    .faincon {
      color: #449d44;
      font-size: .5rem;
      position: absolute;
      right: -.3rem;
      top: -.5rem;
    }
    .text {
      padding: 19px 15px;
      line-height: 22px;
      text-align: center;
      font-size: .35rem;
      color: #fff;

    }
    .operate {
      display: flex;
      align-items: center;
      text-align: center;
      font-size: .3rem;

    }
    .operate-btn {
      flex: 1;
      line-height: 22px;
      padding: 10px 0;
      border-top: 1px solid #ccc;
      color: #fff;
      height: 22px;
    }

  }

  @keyframes confirm-fadein {
    0% {
      opacity: 0
    }
    100% {
      opacity: 1
    }
  }

  @keyframes confirm-zoom {
    0% {
      transform: scale(0)
    }
    50% {
      transform: scale(1.1)
    }
    100% {
      transform: scale(1)
    }
  }

</style>
